<?php


namespace app\login\service;


use app\common\model\Error;
use app\common\service\getPhoneInfoService;
use app\login\model\Registered;
use Driver\Cache\Redis;

class RegisteredService
{
    private $model;
    public function __construct()
    {
        $this->model = new Registered();
    }
    # 获取当天的所有数据并更新状态，每天只能使用八次，每天零点会重置
    public function updateTodayStatus($name)
    {
        $redis_hash_key = config('redis.account_num');
        $num = Redis::hget($redis_hash_key, $name);
        if($num < 1){
            return ['code' => 400, 'num' => 0];
        }
        $json = $this->model->getAll($name);
        $service = new getPhoneInfoService();
        $service->updatePhoneInfo($json);
        # 对应账号当天可点击的次数减一
        Redis::hincrby($redis_hash_key, $name, -1);
        return ['code' => 200, 'num' => $num - 1];

    }
}